<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Db;
class Ustudy extends IndexController
{
    /**
     * 显示学习中心首页
     *
     * @return \think\Response
     */
    public function index($id)
    {
        //查询该用户报名的班级
        $course = Db::name('myclass')->field('cname,cid')->where('uid',session('web')['uid'])->where('cid',$id)->find();
        // dump($course);die;
        //1查询几条答疑放上去
        $rep_question = Db::name('question')->field('title,rpcontent')->limit('4')->where('status','1')->select();
        // dump($rep_question);die;

        $discus = Db::name('together_discus')->field('discontent')->limit('6')->select();
        // dump($discus);die;
        // 
       // var_dump(session('cid'));die;;
        //报了这个班的同学
        $users = Db::name('web_users')->alias('u')->field('u.nickname,u.face,u.id')->join('myclass m','u.id=m.uid')->where('cid',$id)->limit('6')->select();

        //学习任务 
        $class = Db::name('courseunite')->field('id,name,level')->where('courseid',$id)->where('pid','neq','0')->limit(6)->select();
        // dump($users);die;
        return view('ustudy/index',['rep_question'=>$rep_question,'discus'=>$discus,'cid' => $id,'course'=>$course,'users'=>$users,'class'=>$class]);

    }

    /**
     * 我的班级首页
     * @return \think\response\View
     */
    public function changeclass ()
    {
        // 查询课程表
        $data = Db::name('myclass')
            ->field('cid, cname, face, createtime, status')
            ->where('uid', session('web')['uid'])
            ->select();


        return view('ustudy/changeclass', [
            'data' => $data
        ]);

    
    }

    /**
     * 课程视频播放页
     */
    public function classVideo ()
    {
        return view('lesson/lessons');
    }




}
